package com.lzp.test.socket;

import lombok.SneakyThrows;

import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author : lzp
 * @version 1.0
 * @date : 2022/9/13 10:45
 * @apiNote : TODO
 */
public class Server {
    @SneakyThrows
    public static void main(String[] args) {
        ServerSocket serverSocket = new ServerSocket(5000);
        Socket accept = serverSocket.accept();
        InputStream inputStream = accept.getInputStream();
        byte[] bytes = new byte[1024];
        int read = inputStream.read(bytes);
        String s = new String(bytes, 0, read);
        System.out.println("data:"+s);
        accept.close();
        serverSocket.close();
    }
}
